﻿using System;
using System.Text;
using System.Data;
using System.Web.UI.HtmlControls;

namespace LKCMS.Web
{
    public partial class Help : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindMeta("问答中心");
                BindContent();
            }
        }
        private void BindMeta(string classname)
        {
            LKCMS.Model.WebSet webset = new LKCMS.BLL.WebSet().loadConfig(LKCMS.Common.Utils.GetXmlMapPath("Configpath"));

            Page.Title = classname + "_" + webset.WebKeywords;


            //Encode/Content type
            HtmlMeta encode = new HtmlMeta();
            encode.HttpEquiv = "Content-Type";
            encode.Content = "text/html; charset=utf-8";
            Page.Header.Controls.Add(encode);

            //Language
            HtmlMeta lang = new HtmlMeta();
            lang.HttpEquiv = "Content-Language";
            lang.Content = "zh-cn";
            Page.Header.Controls.Add(lang);

            //Description
            HtmlMeta desc = new HtmlMeta();
            desc.Name = "Description";
            desc.Content = webset.WebDescription;
            Page.Header.Controls.Add(desc);

            //Keyword
            HtmlMeta keywords = new HtmlMeta();
            keywords.Name = "keywords";
            keywords.Content = webset.WebKeywords;
            Page.Header.Controls.Add(keywords);

        }
        private void BindContent()
        {
            StringBuilder sb = new StringBuilder();
            StringBuilder sb1 = new StringBuilder();
            LKCMS.BLL.Article abll = new LKCMS.BLL.Article();
            LKCMS.BLL.Channel cbll = new LKCMS.BLL.Channel();
            DataTable dt = cbll.GetList(29);

            sb1.Append("<h2>"+cbll.GetModel(29).Title+"</h2>");
            for (int j=0;j<dt.Rows.Count;j++)
            {
                 DataTable dt1 = abll.GetPageList(4, 0, " ClassId=" + dt.Rows[j]["ID"].ToString(), "AddTime desc").Tables[0];
                 string s = string.Empty;
                 switch (j)
                 {
                     case 0:
                         s = "a";
                         break;
                     case 1:
                         s = "b";
                         break;
                     case 2:
                         s = "c";
                         break;
                     case 3:
                         s = "d";
                         break;
                     case 4:
                         s = "f";
                         break;
                 }
                 sb.Append("<div id=\"help_left_diva\" ><div id=\"help_left_divb\"><p>" + dt.Rows[j]["Title"].ToString() + "</p></div></div>");
                 sb.Append("<ul>");

                for(int i=0;i<dt1.Rows.Count;i++)
                {
                 sb.Append(" <li><a href=\"#"+s+""+(i+1)+"\">"+dt1.Rows[i]["Title"].ToString()+"</a></li>");
                 sb1.Append("<p align=\"left\"><a name=\"" + s + (i + 1) + "\" id=\"" + s + (i + 1) + "\"></a></p>");
                 sb1.Append("<p align=\"left\" class=\"STYLE1\">" + dt1.Rows[i]["Title"].ToString() + "</p>");
                     sb1.Append("<p align=\"left\">&nbsp;</p>");
                     sb1.Append("<p align=\"left\">" + dt1.Rows[i]["Content"].ToString() + "</p>");
                }
                 sb.Append("</ul>");
                 this.LiteralNotes.Text = sb.ToString();
                 this.LiteralContent.Text = sb1.ToString();
             
            }

            
        }

        

        
    }
}
